/*
 * @Description:
 * @version:
 * @Author: sunqian_sr
 * @Date: 2022-11-18 15:33:43
 * @LastEditors: Andy
 * @LastEditTime: 2023-03-03 11:12:12
 */

import { createPinia } from 'pinia'
import settings from './modules/setting'
import cachedView from './modules/cachedView'
import dictValue from './modules/dictValue'

const pinia = createPinia()
export default pinia

const context = import.meta.glob('../../modules/**/pinia/*.js', { eager: true })
let modulesPinias = {
  settings,
  cachedView,
  dictValue
}
Object.keys(context).forEach((key) => {
  const files = key
  const [path, module, base, fileName] = files.replace(/(\..\/|\/module\/|\.js)/g, '').split('/')
  const tempObj = {}
  tempObj[fileName] = context[key].default
  modulesPinias = { ...modulesPinias, ...tempObj }
})

export const pinias = {
  ...modulesPinias
}
